﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TST.SharePointObjects
{
    sealed class SiteObjectComparer
    {
        private static IComparer<SiteObject> _compareByName = new _sortName(false);
        public static IComparer<SiteObject> CompareByName { get { return _compareByName; } }

        private static IComparer<SiteObject> _compareByNameDesc = new _sortName(true);
        public static IComparer<SiteObject> CompareByNameDesc { get { return _compareByNameDesc; } }

        private class _sortName : IComparer<SiteObject>
        {
            bool _reverse;
            public _sortName(bool reverse)
            {
                this._reverse = reverse;
            }

            public int Compare(SiteObject x, SiteObject y)
            {
                if (_reverse) return y.Name.CompareTo(x.Name);
                else return x.Name.CompareTo(y.Name);
            }
        }

    }

}
